package com.fs.utils;




import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.sql.Connection;
import java.util.Properties;

/**
 * 自定义单例类保存Druid数据库连接池对象
 */
public class MyConnectionPool {
    private static DataSource instance;
    private MyConnectionPool(){}

    static {
        Properties prop = new Properties();
        try {
            prop.load(MyConnectionPool.class.getClassLoader().getResourceAsStream("druid.properties"));
            instance = DruidDataSourceFactory.createDataSource(prop);

        } catch (Exception e) {
            e.printStackTrace();

        }
    }


    public  static Connection getConnection() throws  Exception {
        return  instance.getConnection();
    }


}
